function [dPsieffBydLamba] = PsieffDerivative(lambda_i, fVec, Params)
% 
% PSIEFFDERIVATE - compute the derivative of the effective phase 
%
%     Psi_eff = Psi(f; M, eta, t0, phi0) + Phi_C (theta, phi, psi, iota) 
%
% with respect to the parameter lambda_i = {theta, phi, psi, iota, ...
%     log(M), log(eta), log(dL)}. 
% 
% usage: [dPsieffBydLamba] = PsieffDerivative(lambda_i, fVec, Params)
% 
% P. Ajith, 7 Aug 2009
% 
% $Id: PsieffDerivative.m 59 2010-01-20 21:41:01Z anand.sengupta $

    setconstants

    M = Params.totalMass*MSOLAR_TIME;
    eta = Params.eta;
    dL = Params.dL*PARSEC_SEC*1e6;
    theta  = Params.theta;
    phi = Params.phi;
    psi = Params.psi;
    iota = Params.iota;
    Det = Params.Det;

    switch lambda_i 
        case 'M'
            [dPsiBydM] = dPsiPNbydM(fVec, Params);
            dPsieffBydLamba = M*dPsiBydM;       % returned derivative is w.r.t log(M)
        case 'eta'
            [dPsiBydEta] = dPsiPNbydEta(fVec, Params);
            dPsieffBydLamba = eta*dPsiBydEta;   % returned derivative is w.r.t log(M)
        case 'theta'
            [dPhiCBydTheta] = dPhi0_dtheta(phi, theta, psi, iota, Det);
            dPsieffBydLamba = dPhiCBydTheta*ones(size(fVec));
        case 'phi'
            [dPhiCBydPhi] = dPhi0_dphi(phi, theta, psi, iota, Det);
            dPsieffBydLamba = dPhiCBydPhi*ones(size(fVec));
        case 'dL'
            dPsieffBydLamba = zeros(size(fVec));
        case 'psi'
            [dPhiCBydPsi] = dPhi0_dpsi(phi, theta, psi, iota, Det);
            dPsieffBydLamba = dPhiCBydPsi*ones(size(fVec));
        case 'iota'
            [dPhiCBydIota] = dPhi0_diota(phi, theta, psi, iota, Det);
            dPsieffBydLamba = dPhiCBydIota*ones(size(fVec));
        case 't0'
            dPsieffBydLamba = 2*pi*fVec;
        case 'phi0'
            dPsieffBydLamba = ones(size(fVec));
    end

